import QtQuick 2.12
import QtQuick.Window 2.12
import BppTable 1.0

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    CompGrid {
        id: bGrid
        anchors.fill: parent
        anchors.margins: 10

        dataHeight: 30

        Component {
            id: cellItem

            Rectangle {
                implicitHeight: bGrid.dataHeight
                color: bGrid.getCellBk(row, highlight)

                CellText {
                    text: bGrid.formatDisplay(display, dataType, 2)
                    horizontalAlignment: bGrid.getAlign(dataType)
                }

                CellClicker {
                    grid: bGrid
                }
            }
        }

        cellDelegate: cellItem

        fromArray: [ //column def here
            { title: "ID", dataType: "Int" },
            { title: "Name", minWidth: 100 },
            { title: "Cost", dataType: "Dbl" }
         ]
    }

    Component.onCompleted: {
        let arr=[]
        let i=0;
        while(i<100){
            arr.push([i,"ab",i/10.0]);
            i+=1
        }
        bGrid.fillFromArray(arr);
    }
}
